﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Cpjit.SunnyPaine.Toolkit.Test.Util
{
    public class Messenger
    {
        private readonly IDictionary dict = new Dictionary<string, object>();


        private static readonly Messenger instance = new Messenger();
        public static Messenger Instance
        {
            get { return instance; }
        }



        public void Register<T>(string token, Action<T> action)
        {
            dict.Add(token, action);
        }

        public void Send<T>(string token, T message)
        {
            if (dict.Contains(token))
            {
                Action<T> action = (Action<T>)dict[token];
                action(message);
            }
        }
    }
}
